package au.edu.adelaide.mips_soft_core.board_interface_pc.logger;

import java.util.ArrayList;

public class Logger {
	
	private ArrayList<LoggerListener> listeners = new ArrayList<LoggerListener>();
	
	private int[] levels;
	private String[] levelNames;
	
	public Logger(int[] levels, String[] levelNames){
		this.levels = levels;
		this.levelNames = levelNames;
	}
	
	public void write(String message, int level){
		long time = System.currentTimeMillis();
		for(int i = 0; i < listeners.size(); i++){
			LoggerListener listener = listeners.get(i);
			if(listener.minLevel() <= level){
				listeners.get(i).message(time, message, level);
			}
		}
	}
	
	public void addListener(LoggerListener listener){
		listeners.add(listener);
	}
	
	public void removeListener(LoggerListener listener){
		listeners.remove(listener);
	}
	
	
	public interface LoggerListener{
		
		public int minLevel();
		
		public void message(long time, String message,  int level);
		
	}
	
	

}
